import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';



///
///  调用第三方包
///
class LearnApp02 extends StatelessWidget{
  const LearnApp02({super.key});

  Future<void> _lanchUrl(Uri url) async{
    if(!await launchUrl(url)){
      throw "浏览器无法打开 $url";  
    }
  }
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return  MaterialApp(
        title: "使用第三方包实例",
        debugShowCheckedModeBanner: false,
        home: Scaffold(
          body:  Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              const Text("这是一个跳转的测试"),
              ElevatedButton(onPressed: (){
                final Uri url = Uri.parse("https://www.baidu.com/");
                _lanchUrl(url);
              }, child: const Text("跳转页面"))
            ],
          )
        ),
    );
  }
}

